#include <iostream>
#include <string>
#include "textContent.h"

using std::string;
using std::cout;
using std::map;

textContent::textContent(void)
{
}

textContent::textContent(int numOfWords)
{
	codeArray = new int[numOfWords];
	posCount = 0;
	wordCount = 0;
}

textContent::textContent(int numOfWords, int wordListLenght)
{
	codeArray = new int[numOfWords];
	posCount = 0;
	wordCount = 0;
}

void textContent::addWord(string word)
{
	map<string, int>::iterator it;
	it = wordMap.find(word);
	
	if(it != wordMap.end())
	{
		codeArray[posCount] = int(it->second);
		posCount++;
	}
	else
	{
		wordMap[word] = wordCount;
		codeArray[posCount] = wordCount;
		posCount++;
		wordCount++;
	}
}

void textContent::printud()
{
	map<string, int>::iterator i;
	map<string, int>::iterator iend = wordMap.end();
	for(i=wordMap.begin();i!=iend;++i)
	{
		cout << i->first << " " << i->second << std::endl;
	}

	for(int h=0;h<8;h++)
	{
		cout << codeArray[h] <<  " ";

	}

}

textContent::~textContent(void)
{
}
